﻿using jlynet.core.notebook.util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace jlynet.core.notebook.myform
{
    public partial class DialogForm : Form
    {
        public DialogForm()
        {
            InitializeComponent();
        }

        public DialogForm(string text, string caption, MsgBoxButtons buttons, MsgBoxIcon icon)
        {
            this.Text = caption;
            label1.Text = text;
            //pictureBox1. = icon;
            SetButton(buttons);

            //MsgBoxHelper.Show("程序已崩溃，请重启!", "系统崩溃", MsgBoxButtons.OKCancel, MsgBoxIcon.SysBreak);
            //MsgBoxHelper.Show("密码错误！", "错误", MsgBoxButtons.OK, MsgBoxIcon.Error);
            //MsgBoxHelper.Show("您确定要退出系统？", "警告", MsgBoxButtons.YesNo, MsgBoxIcon.Warning);

        }

        

        // <summary>
        /// 设置按钮
        /// </summary>
        /// <param name="button">需产生的按钮组</param>
        private void SetButton(MsgBoxButtons buttons)
        {
            int width = this.pnlButtonContainer.Width / 2;
            int height = this.pnlButtonContainer.Height;
            int x = 0, y = 0;
            switch (buttons)
            {
                case MsgBoxButtons.OK:
                    {

                        x = width - 30;
                        y = height - 30;
                        //“确认”按钮
                        Button btn1 = new Button();
                        btn1.Size = new Size(75, 23);
                        btn1.Font = new Font("宋体", 9);
                        btn1.Location = new Point(x, y);
                        btn1.Name = "btnOK";
                        btn1.Text = MsgBoxButtonText.OK;
                        btn1.Click += btnOK_Click;
                        pnlButtonContainer.Controls.Add(btn1);

                    }
                    break;
                case MsgBoxButtons.OKCancel:
                    {
                        x = width - 80;
                        y = height - 30;
                        //“确认”按钮
                        Button btn1 = new Button();
                        btn1.Size = new Size(75, 23);
                        btn1.Font = new Font("宋体", 9);
                        btn1.Location = new Point(x, y);
                        btn1.Name = "btnOK";
                        btn1.Text = MsgBoxButtonText.OK;
                        btn1.Click += btnOK_Click;
                        pnlButtonContainer.Controls.Add(btn1);


                        x = width + 5;
                        y = height - 30;
                        //“取消”按钮
                        Button btn2 = new Button();
                        btn2.Size = new Size(75, 23);
                        btn2.Font = new Font("宋体", 9);
                        btn2.Location = new Point(x, y);
                        btn2.Name = "btnCancel";
                        btn2.Text = MsgBoxButtonText.Cancel;
                        btn2.Click += btnCancel_Click;
                        pnlButtonContainer.Controls.Add(btn2);

                    }
                    break;
                case MsgBoxButtons.YesNo:
                    {
                        x = width - 80;
                        y = height - 30;
                        //“是”按钮
                        Button btn1 = new Button();
                        btn1.Size = new Size(75, 23);
                        btn1.Font = new Font("宋体", 9);
                        btn1.Location = new Point(x, y);
                        btn1.Name = "btnYes";
                        btn1.Text = MsgBoxButtonText.Yes;
                        btn1.Click += btnYes_Click;
                        pnlButtonContainer.Controls.Add(btn1);

                        x = width + 5;
                        y = height - 30;
                        //“否”按钮
                        Button btn2 = new Button();
                        btn2.Size = new Size(75, 23);
                        btn2.Font = new Font("宋体", 9);
                        btn2.Location = new Point(x, y);
                        btn2.Name = "btnNo";
                        btn2.Text = MsgBoxButtonText.No;
                        btn2.Click += btnNo_Click;
                        pnlButtonContainer.Controls.Add(btn2);

                    }
                    break;
                case MsgBoxButtons.YesNoCancel:
                    {
                        x = width - 120;
                        y = height - 30;
                        //“是”按钮
                        Button btn1 = new Button();
                        btn1.Size = new Size(75, 23);
                        btn1.Font = new Font("宋体", 9);
                        btn1.Location = new Point(x, y);
                        btn1.Name = "btnYes";
                        btn1.Text = MsgBoxButtonText.Yes;
                        btn1.Click += btnYes_Click;
                        pnlButtonContainer.Controls.Add(btn1);

                        x = width - 35;
                        y = height - 30;
                        //“否”按钮
                        Button btn2 = new Button();
                        btn2.Size = new Size(75, 23);
                        btn2.Font = new Font("宋体", 9);
                        btn2.Location = new Point(x, y);
                        btn2.Name = "btnNo";
                        btn2.Text = MsgBoxButtonText.No;
                        btn2.Click += btnNo_Click;
                        pnlButtonContainer.Controls.Add(btn2);

                        x = width + 50;
                        y = height - 30;
                        //“取消”按钮
                        Button btn3 = new Button();
                        btn3.Size = new Size(75, 23);
                        btn3.Font = new Font("宋体", 9);
                        btn3.Location = new Point(x, y);
                        btn3.Name = "btnCancel";
                        btn3.Text = MsgBoxButtonText.Cancel;
                        btn3.Click += btnCancel_Click;
                        pnlButtonContainer.Controls.Add(btn3);

                    }
                    break;
                case MsgBoxButtons.AbortRetryIgnore:
                    {
                        x = width - 120;
                        y = height - 30;
                        //“终止”按钮
                        Button btn1 = new Button();
                        btn1.Size = new Size(75, 23);
                        btn1.Font = new Font("宋体", 9);
                        btn1.Location = new Point(x, y);
                        btn1.Name = "btnAbort";
                        btn1.Text = MsgBoxButtonText.Abort;
                        btn1.Click += btnAbort_Click;
                        pnlButtonContainer.Controls.Add(btn1);

                        x = width - 35;
                        y = height - 30;
                        //“重试”按钮
                        Button btn2 = new Button();
                        btn2.Size = new Size(75, 23);
                        btn2.Font = new Font("宋体", 9);
                        btn2.Location = new Point(x, y);
                        btn2.Name = "btnRetry";
                        btn2.Text = MsgBoxButtonText.Retry;
                        btn2.Click += btnRetry_Click;
                        pnlButtonContainer.Controls.Add(btn2);

                        x = width + 50;
                        y = height - 30;
                        //“忽略”按钮
                        Button btn3 = new Button();
                        btn3.Size = new Size(75, 23);
                        btn3.Font = new Font("宋体", 9);
                        btn3.Location = new Point(x, y);
                        btn3.Name = "btnIgnore";
                        btn3.Text = MsgBoxButtonText.Ignore;
                        btn3.Click += btnIgnore_Click;
                        pnlButtonContainer.Controls.Add(btn3);


                    }
                    break;
                case MsgBoxButtons.RetryCancel:
                    {
                        x = width - 80;
                        y = height - 30;
                        //“重试”按钮
                        Button btn1 = new Button();
                        btn1.Size = new Size(75, 23);
                        btn1.Font = new Font("宋体", 9);
                        btn1.Location = new Point(x, y);
                        btn1.Name = "btnRetry";
                        btn1.Text = MsgBoxButtonText.Retry;
                        btn1.Click += btnRetry_Click;
                        pnlButtonContainer.Controls.Add(btn1);

                        x = width + 5;
                        y = height - 30;
                        //“取消”按钮
                        Button btn2 = new Button();
                        btn2.Size = new Size(75, 23);
                        btn2.Font = new Font("宋体", 9);
                        btn2.Location = new Point(x, y);
                        btn2.Name = "btnCancel";
                        btn2.Text = MsgBoxButtonText.Cancel;
                        btn2.Click += btnCancel_Click;
                        pnlButtonContainer.Controls.Add(btn2);

                    }
                    break;
                case MsgBoxButtons.OKCopy:
                    {
                        x = width - 80;
                        y = height - 30;
                        //“确认”按钮
                        Button btn1 = new Button();
                        btn1.Size = new Size(75, 23);
                        btn1.Font = new Font("宋体", 9);
                        btn1.Location = new Point(x, y);
                        btn1.Name = "btnOK";
                        btn1.Text = MsgBoxButtonText.OK;
                        btn1.Click += btnOK_Click;
                        pnlButtonContainer.Controls.Add(btn1);

                        x = width + 5;
                        y = height - 30;
                        //“复制”按钮
                        Button btn2 = new Button();
                        btn2.Size = new Size(75, 23);
                        btn2.Font = new Font("宋体", 9);
                        btn2.Location = new Point(x, y);
                        btn2.Name = "btnCopy";
                        btn2.Text = MsgBoxButtonText.Copy;
                        btn2.Click += btnCopy_Click;
                        pnlButtonContainer.Controls.Add(btn2);

                    }
                    break;
                default:
                    {
                        x = width - 30;
                        y = height - 30;
                        //“确认”按钮
                        Button btn1 = new Button();
                        btn1.Size = new Size(75, 23);
                        btn1.Font = new Font("宋体", 9);
                        btn1.Location = new Point(x, y);
                        btn1.Name = "btnOK";
                        btn1.Text = MsgBoxButtonText.OK;
                        btn1.Click += btnOK_Click;
                        pnlButtonContainer.Controls.Add(btn1);
                    }
                    break;
            }
        }

        private void btnAbort_Click(object sender, EventArgs e)
        {

        }

        private void btnIgnore_Click(object sender, EventArgs e)
        {


        }

        private void btnNo_Click(object sender, EventArgs e)
        {


        }

        private void btnOK_Click(object sender, EventArgs e)
        {


        }

        private void btnRetry_Click(object sender, EventArgs e)
        {

        }

        private void btnYes_Click(object sender, EventArgs e)
        {

        }

        private void btnCancel_Click(object sender, EventArgs e)
        {


        }

        private void btnCopy_Click(object sender, EventArgs e)
        {
            

        }

    }
}
